/**
 * Malsha 2014-11-19
 */

RepIssuer = new Object();
var issuer_category = Ext.create('Ext.data.Store', {
	fields : [ 'id', 'code', 'issureCategory', 'primaryDealer' ],
});
RepIssuer.getBasicDetails = function() {
	return Ext.create('Ext.form.FieldSet', {
		defaults : {
			anchor : '100%'
		},
		items : [ {
			xtype : 'combo',
			fieldLabel : 'Issuer Category',
			valueField : 'id',
			id : 'issuer_category',
			store : issuer_category,
			queryMode : 'local',
			msgTarget : 'under',
			displayField : 'issureCategory',
			isLoaded : false,
			name : 'issuerTypeId',
			emptyText : 'Select a Issuer Category...',
			listeners : {
				expand : function(combo, opt) {
					if (!combo.isLoaded) {
						Ext.Ajax.request({
							url : 'getAllIssuerTypes.action',
							success : function(response) {
								var obj = Ext.decode(response.responseText);
								combo.getStore().loadRawData(obj.issuerTypeDtos);
								combo.isLoaded = true;
							}
						});
					}
				}
			}
		} ]
	});
};

RepIssuer.getCenterPanel = function() {

	var feilds = RepIssuer.getBasicDetails();
	formpanel = Ext.create('Ext.form.Panel', {
		title : 'Issuer',
		bodyPadding : 20,
		autoScroll : true,
		frame : true,
		defaults : {
			labelWidth : 110,
			anchor : '65%',
		},
		items : [ feilds ],
		buttonAlign : 'center',
		buttons : [ {
			text : 'Cancel',
			handler : function() {
				App.Core.removeScreen();
			}
		}, {
			text : 'Reset',
			handler : function() {
			}
		}, {
			text : 'Print',
			handler : function(grid, rowIndex, colIndex) {
				var param = {
					'issuerType' : Ext.getCmp('issuer_category').getValue() != null ? Ext.getCmp('issuer_category').getValue() : "%"
				};
				Report.OpenWindowWithPost('ReportServlet/IssuerList', "width=1000, height=600, left=100, top=100,resizable=yes, scrollbars=yes", "NewFile", param);
			}
		} ]
	});
	return formpanel;

};